<?php

namespace app\admin\model;

use think\Model;


class IncomeDetail extends Model
{

    

    

    // 表名
    protected $name = 'income_detail';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'create_time_text',
    ];
    
    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['createtime']) ? $data['createtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    

   public function user()
    {
        return $this->belongsTo('user', 'user_id');
    }
    





}
